#include <stdio.h>
#include "Utils.h"
#include "LeNetINT8.h"

#define skip 10

//proto accurate is 0.6739
//this accurate is 0.6677 decrease 0.0062
#include "TensorStack.h";
using namespace std;
int main()
{
	TensorStack stack;
	auto tensF = DL::Tensor1D<float>(1);
	auto tensI = DL::Tensor1D<int8>(1);
	stack.AddTensor("1", tensF);
	stack.AddTensor("1", tensI);

	LeNetINT8 module("..\\refer\\LeNetINT8.json");
	vector<string> files = getFilesList("..\\test");
	int total = files.size();
	int accurate = 0;
	int k = 0;
	for (int i = 0; i < total; i++)
	{
		k++;
		if (k < skip)  continue;
		k = 0;

		string filepath = files[i];
		int accurateIndex = filepath[filepath.find_last_of('_') - 1] - '0';
		Image image(filepath);
		int index = module.GetResultIndex(image);
		if (index == accurateIndex)
			accurate++;
		printf("index:%d,%s\r\n", i, index == accurateIndex ? "success" : "fail");
	}
	printf("Test accurate rate is %f", (accurate / (float)total * skip));
	return 0;
}

